<?php

/**
 * 描述：配送地址信息的个数
 * @param  string
 * @return array
 */
function getcnt_address($cust_id){
	$mod = new CustAddressModel();
	$modWhere  = array( 
		'cust_id'=>$cust_id
	);
	$count = $mod->setModWhere($modWhere)->count();
	return $count;
}

/**
 * 描述：购物车中物品的数量
 * @param  string
 * @return array
 */
function getcnt_cartitem(){
	$cart = cookie(COK_CART);
	return count($cart);
}

function check_cartitemnum($itemNum){
	if($itemNum==0){
		return true;
	}else if(intval($itemNum)){
		return true;
	}else{
		return false;
	}
}
/**
 * 描述：获得商品的库存ID和规格数量
 * @param  string
 * @return array
 */
function get_prod_stock_ref($prod_id){
	$mod = new ProductLibModel();
	$detail = $mod->field('stock_prod_id,spec_qty')->find($prod_id);//查询商品的库存参照id
	if($detail['stock_prod_id']==0){
		$detail['stock_prod_id'] = $prod_id;
	}
	return $detail;
}
/**
 * 描述：获得商品的单品库存量 $stock_prod_id:单品的商品ID
 * @param  string
 * @return array
 */
function get_prod_stock_qty($shop_id,$stock_prod_id){
	$modWhere['shop_id'] = $shop_id;
	$modWhere['prod_id'] = $stock_prod_id;
	$mod = new ProductPriceModel();
	$detail = $mod->field('stock_qty')->where($modWhere)->find();//不考虑商品时候有效还是上架
	return intval($detail['stock_qty']);
}

function get_shop_setting($shop_id,$type){
	$modWhere['shop_id'] = $shop_id;
	$modWhere['is_show'] = 1;
	$modWhere['type'] = $type;
	$mod = new CommonModel('ShopSetting');
	$list = $mod->setModWhere($modWhere)->order('ordlist')->select();
	return $list;
}

?>